package com.nowcoder.utils;

import com.nowcoder.entity.User;
import org.springframework.stereotype.Component;

import javax.jws.soap.SOAPBinding;

/**
 * @Author liujilong
 * @Project nowcoder
 * @File HostHolder 持有用户信息，用于代替Session对象
 * @Date 2021/12/28 1:57 下午
 **/
@Component
public class HostHolder {

    private ThreadLocal<User> users = new ThreadLocal<>();

    public void setUser(User user) {
        users.set(user);
    }

    public User getUser() {
        return users.get();
    }

    public void clear() {
        users.remove();
    }
}
